// 开发场景定义
export interface DevelopmentScene {
  id: number;
  name: string;
  description: string;
  category: string;
}

// 开发场景列表
export const developmentScenes: DevelopmentScene[] = [
  {
    id: 1,
    name: '系统编程',
    description: '操作系统开发、设备驱动程序等',
    category: 'system'
  },
  {
    id: 2,
    name: 'WebAssembly',
    description: 'Wasm应用开发',
    category: 'web'
  },
  {
    id: 3,
    name: '命令行工具',
    description: '系统工具、开发工具、文件处理工具等',
    category: 'cli'
  },
  {
    id: 4,
    name: '网络编程',
    description: '高性能Web服务器、API服务、网络协议实现',
    category: 'network'
  },
  {
    id: 5,
    name: '区块链和加密货币',
    description: '智能合约平台、加密货币实现、DeFi应用',
    category: 'blockchain'
  },
  {
    id: 6,
    name: '游戏开发',
    description: '游戏引擎、游戏服务器、物理引擎',
    category: 'game'
  },
  {
    id: 7,
    name: '数据处理和分析',
    description: '大数据处理、数据分析工具、ETL工具',
    category: 'data'
  },
  {
    id: 8,
    name: '并发和分布式系统',
    description: '分布式计算框架、消息队列系统、集群管理',
    category: 'distributed'
  },
  {
    id: 9,
    name: '安全工具',
    description: '密码学工具、安全审计工具、漏洞扫描器',
    category: 'security'
  },
  {
    id: 10,
    name: '跨平台开发',
    description: 'GUI应用（Tauri/GTK）、移动应用、多平台工具',
    category: 'cross-platform'
  }
];

// 容器环境类型
export type ContainerEnv = 'dev' | 'test' | 'prod';

// 系统配置
export interface SystemConfig {
  timezone: string;
  locale: {
    lang: string;
    lcAll: string;
  };
  mirrors: {
    apt: string;
    rustup: string;
    cargo: string;
  };
}

// 工具链配置
export interface ToolchainConfig {
  basic: boolean;     // git, curl等基础工具
  buildTools: boolean; // build-essential, cmake
  llvm: boolean;      // LLVM工具链
  ssl: boolean;       // SSL支持
  database: boolean;  // 数据库依赖
  docker: boolean;    // Docker支持
}

// Rust配置
export interface RustConfig {
  version: string;
  profile: 'minimal' | 'default' | 'complete';
  components: {
    rustAnalyzer: boolean;
    clippy: boolean;
    rustfmt: boolean;
    rustSrc: boolean;
  };
  tools: {
    cargoWatch: boolean;
    cargoEdit: boolean;
  };
}

// IDE配置
export interface IDEConfig {
  type: 'vscode' | 'cursor' | 'none';
  extensions: string[];
  ssh: boolean;
}

// 容器配置
export interface ContainerConfig {
  env: ContainerEnv;
  name: string;
  baseImage: string;
  ports: number[];
  system: SystemConfig;
  toolchain: ToolchainConfig;
  rust: RustConfig;
  ide: IDEConfig;
  container: {
    baseOS?: string;
    systemTools?: string[];
    enableCache?: boolean;
    cacheDir?: string;
    optimizationLevel?: string;
    devToolchain?: string;
    devTools?: string[];
    testFrameworks?: string[];
    testParallel?: number;
    prodOptimizations?: string[];
    targetArch?: string;
  };
}

// 默认配置
export const DEFAULT_CONFIGS: Record<ContainerEnv, Partial<ContainerConfig>> = {
  dev: {
    baseImage: 'rust:1.75-slim-bullseye',
    system: {
      timezone: 'UTC',
      locale: {
        lang: 'en_US.UTF-8',
        lcAll: 'en_US.UTF-8'
      },
      mirrors: {
        apt: 'mirrors.aliyun.com',
        rustup: 'https://rsproxy.cn',
        cargo: 'https://rsproxy.cn/crates.io-index'
      }
    },
    toolchain: {
      basic: true,
      buildTools: true,
      llvm: true,
      ssl: true,
      database: true,
      docker: true
    },
    rust: {
      version: '1.75',
      profile: 'complete',
      components: {
        rustAnalyzer: true,
        clippy: true,
        rustfmt: true,
        rustSrc: true
      },
      tools: {
        cargoWatch: true,
        cargoEdit: true
      }
    },
    ide: {
      type: 'cursor',
      extensions: [
        'rust-lang.rust-analyzer',
        'tamasfe.even-better-toml',
        'serayuzgur.crates'
      ],
      ssh: true
    },
    container: {
      baseOS: 'ubuntu',
      systemTools: ['git', 'curl', 'wget'],
      enableCache: true,
      cacheDir: '/root/.cargo/cache',
      optimizationLevel: '2',
      devToolchain: 'stable',
      devTools: ['clippy', 'rustfmt'],
      testFrameworks: ['cargo-test'],
      testParallel: 4,
      prodOptimizations: ['lto'],
      targetArch: 'native'
    }
  },
  test: {
    baseImage: 'debian:bullseye-slim',
    system: {
      timezone: 'UTC',
      locale: {
        lang: 'en_US.UTF-8',
        lcAll: 'en_US.UTF-8'
      },
      mirrors: {
        apt: 'mirrors.aliyun.com',
        rustup: 'https://rsproxy.cn',
        cargo: 'https://rsproxy.cn/crates.io-index'
      }
    },
    toolchain: {
      basic: true,
      buildTools: false,
      llvm: false,
      ssl: true,
      database: true,
      docker: false
    },
    rust: {
      version: '1.75',
      profile: 'minimal',
      components: {
        rustAnalyzer: false,
        clippy: false,
        rustfmt: false,
        rustSrc: false
      },
      tools: {
        cargoWatch: false,
        cargoEdit: false
      }
    },
    ide: {
      type: 'none',
      extensions: [],
      ssh: false
    },
    container: {
      baseOS: 'debian',
      systemTools: ['git'],
      enableCache: false,
      optimizationLevel: '1',
      devToolchain: 'stable',
      devTools: ['clippy'],
      testFrameworks: ['cargo-test'],
      testParallel: 2,
      prodOptimizations: [],
      targetArch: 'x86_64'
    }
  },
  prod: {
    baseImage: 'debian:bullseye-slim',
    system: {
      timezone: 'UTC',
      locale: {
        lang: 'en_US.UTF-8',
        lcAll: 'en_US.UTF-8'
      },
      mirrors: {
        apt: 'mirrors.aliyun.com',
        rustup: 'https://rsproxy.cn',
        cargo: 'https://rsproxy.cn/crates.io-index'
      }
    },
    toolchain: {
      basic: false,
      buildTools: false,
      llvm: false,
      ssl: true,
      database: true,
      docker: false
    },
    rust: {
      version: '1.75',
      profile: 'minimal',
      components: {
        rustAnalyzer: false,
        clippy: false,
        rustfmt: false,
        rustSrc: false
      },
      tools: {
        cargoWatch: false,
        cargoEdit: false
      }
    },
    ide: {
      type: 'none',
      extensions: [],
      ssh: false
    },
    container: {
      baseOS: 'alpine',
      systemTools: [],
      enableCache: false,
      optimizationLevel: '3',
      devToolchain: 'stable',
      devTools: [],
      testFrameworks: [],
      testParallel: 1,
      prodOptimizations: ['lto', 'strip'],
      targetArch: 'x86_64'
    }
  }
};

// VS Code 扩展
export const VSCODE_EXTENSIONS = {
  base: [
    'rust-lang.rust-analyzer',
    'tamasfe.even-better-toml',
    'serayuzgur.crates',
    'vadimcn.vscode-lldb'
  ],
  clippy: 'rust-lang.clippy-lints'
};

// 中国区镜像配置
export const CHINA_MIRROR_CONFIG = {
  "RUSTUP_DIST_SERVER": "https://mirrors.ustc.edu.cn/rust-static",
  "RUSTUP_UPDATE_ROOT": "https://mirrors.ustc.edu.cn/rust-static/rustup",
  "CARGO_REGISTRY_INDEX": "https://mirrors.ustc.edu.cn/crates.io-index"
}; 